<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/style.css" media="all"/>

	<script src="js/jquery-1.8.2.min.js" ></script>
	<script src="js/image.js" type="text/javascript"></script>
	<script src="../js/checkUser.js" type="text/javascript"></script>
	<script src="../js/checkEmail.js" type="text/javascript"></script>
         <script src="../js/jsearch.js" type="text/javascript"></script>  
	<script type="text/javascript">
	function checkPass()
	{
		var pass= document.getElementById("txtpass").value;
		var passc =document.getElementById("txtconfim").value;
		if(pass!=passc)
		{
			document.getElementById("confim").innerHTML="<img src='images/error.png'>Mật khẩu phải giống nhau</img>";
			document.getElementById("txtconfim").value="";
		}
		else {	document.getElementById("confim").innerHTML="*";}
	}
	function resetform()
	{
		document.getElementById("txtname").value="";
	}
	function register()
	{
		var cname=document.getElementById("checkname").value;
		var pass=document.getElementById("txtpass").value;
		var passc=document.getElementById("txtconfim").value;
		var cemail=document.getElementById("checkEmail").value;	
		var name=document.getElementById("txtname").value;
		var email=document.getElementById("txtemail").value;
		if(name=='false' || cemail=='false' || pass=="" || passc=="")
		{
		 	document.getElementById("test").innerHTML="<p style ='color:red'>Đăng ký không thành công, kiểm tra dữ liệu nhập vào</p>";
			return 
		}
		else
		{
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			 var rl=xmlhttp.responseText;
			 if (rl==1)
			 {
			  	window.location ="v_login.php"; 
			 }
			 else
				{
				document.getElementById("test").innerHTML="Lỗi khi đăng ký!";
				}
			}
		  }
		  var url= "c_register.php?name="+name+"&pass=" +pass+"&email="+email;
		xmlhttp.open("GET",url,true);
		xmlhttp.send();
		}
	}
	</script>
	
<title>Untitled Document</title>
</head>

<body class="pagebody" onLoad="javascript:resetform()">
	<div id="wrapwebsite" >
				<?php 
				ob_start();
			include('../element/header.php');
			if(isset($_SESSION['user'])) 
			{
				unset($_SESSION['user']);
			}
			?>
			<div class="imagestop"></div>
		<div class="wrapmaincontent">
		<?php
		include('../element/leftside.php');
		?>
		<div class="center-leftmargin">
			<div class="register">
				<div class="moduletitle" ><h2>  Đăng ký </h2></div>
				<div class="modulecontent">
				<div class="frmregister">
				<form action="javascript:register()" method="post" id="frmregister">
					<div class="row">
					<label for="txtname"> Tên đăng nhập :</label><input  type="text" id="txtname" name="txtname" size="30px;" onBlur="checkUsername(this.value);"/>&nbsp;<span id="errorusername">*</span>
					</div>
						<div class="row">
					<label for="txtpass"> Mặt khẩu :</label><input type="password" id="txtpass" name="txtpass" size="30px"/>&nbsp;<span id="">*</span>
					</div>
						<div class="row">
					<label for="txtconfim"> Nhập lai mật khẩu :</label><input type="password" id="txtconfim" name="txtconfim" size="30px" onBlur="checkPass();"/>&nbsp;<span id="confim">*</span>
					</div>
						<div class="row">
					<label for="txtemail"> Email :</label><input type="text" id="txtemail" name="txtemail" size="30px" onBlur="checkEmail(this.value);"/>&nbsp;<span id="erroremail">*</span>
					</div>
					<div class="row" ><span id="test"></span></div>
					<div class="row-last" >
						<input type="submit" value="Đăng ký"  class="button" /><input type="reset" value="Reset" class="button"/>
 					</div>
					</form>
				</div>
				</div>
			</div>
		</div> 
		</div>
		<?php include('../element/footer.php'); ?>
</div>
</body>
</html>
